/**
 * @file   1094.cpp
 * @author Shuang Hu <hsmath@ubuntu>
 * @date   Mon Apr 19 21:20:53 2021
 * 
 * @brief  PAT 1094,BFS
 * 
 * 
 */

#include<iostream>
#include<vector>
#include<map>
#include<queue>
using namespace std;
class Homemap{
private:
    map<int,vector<int>> AdjTable;//Mark the family members
    map<int,int> height;//Mark the height of all the nodes
    int HNodenum[105]={0};//Mark the heightnum
    int h;
    int mnum;
    int member;//Member num
public:
    Homemap(int n,int looptime);
    void BFS();//Binary-first search
    void stat();//generate Heightnum
    void printinfo();
};
Homemap::Homemap(int n,int looptime){
    member=n;
    for(int i=0;i<looptime;i++){
	int id,num;
	cin>>id>>num;
	for(int j=0;j<num;j++){
	    int _id;
	    cin>>_id;
	    AdjTable[id].push_back(_id);
	}
    }
    h=0;
    mnum=0;
}
void Homemap::BFS(){
    queue<int> Q;
    Q.push(1);
    height[1]=1;
    while(Q.size()){
	int tmp=Q.front();
	Q.pop();
	for(int i=0;i<AdjTable[tmp].size();i++){
	    Q.push(AdjTable[tmp][i]);
	    height[AdjTable[tmp][i]]=height[tmp]+1;
	}
    }
}
void Homemap::stat(){
    for(auto it=height.begin();it!=height.end();it++){
	HNodenum[it->second]++;
    }
    for(int i=1;i<=member;i++){
	if(HNodenum[i]>mnum){
	    h=i;
	    mnum=HNodenum[i];
	}
    }
}
void Homemap::printinfo(){
    cout<<mnum<<" "<<h<<endl;
}
int main(){
    int a,v;
    cin>>a>>v;
    Homemap M(a,v);
    M.BFS();
    M.stat();
    M.printinfo();
}
